<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title> 用户登录 - <{$smarty.const.WEB_NAME}> </title>
	<link rel="stylesheet" type="text/css" href="./skin/<{$smarty.const.TPL_NAME}>/style.css" />
</head>
 <body onload="verifyNumber()">
	 <style type="text/css">
	   <!--
	     body {
		   background-color:#fafaf9
		 }
	     #tableList {
		  width:340px;
		  background: url(skin/<{$smarty.const.TPL_NAME}>/left_bg.png) repeat-x;
		 }
	     #tableList td , #tableList th{
		  text-indent:0;
		  line-height:35px;
		  text-align:center;
		 }
		 .input_1 {
		  height:19px;
		  line-height:19px;
		 }
	   //-->
	 </style>
	 
<form method="post" id="form" action="index.php?q=volidLogin">	
	  <table border="1" cellspacing="0" bordercolor="#cfcfcd" cellpadding="0"  id="tableList" style="margin:150px auto">
		<tr>		  
		  <th colspan="2" align="left">
            <table cellspacing="0" cellpadding="0" align="left">
				<tr>
					<td width="100"><img src="skin/<{$smarty.const.TPL_NAME}>/face.gif" /></td>
					<td valign="bottom"><h1>内部管理系统</h1></td>
				</tr>
            </table>
		  </th>
		</tr>
		<tr class="tit">		  
		  <th>用户名称(u)</th>
		  <th align="left"><span style="float:left"> <input type="text" name="userName" id="userName" class="input_1" accesskey="u" /></span></th>
		</tr>
		<tr>
          <td><b>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码(p)</b></td>
		  <th align="left">
		  <span style="float:left"> <input type="password" name="pass" id="pass"  class="input_1" accesskey="p" style="width:147px"/></span>
		  <div class="none" id="old_tip">&nbsp;</div>
		  </th>
		</tr>
		<tr id="inputCode" class="none">
          <td><b>验&nbsp;&nbsp;证&nbsp;&nbsp;码(c)</b></td>
		  <th align="left"><span style="float:left"> 
		  <input type="text" name="code" id="code" class="input_1" maxlength="4" accesskey="c" onkeyup="value=value.replace(/[^\d]/g,'')" style="width:40px;" />
		 <img src="getCode.php" onclick="this.src='getCode.php?q='+Math.random(1)" style="cursor:hand" title="点击换一张" />
			</span></th>
		</tr>
		<tr>
		  <td colspan="2" align="center">
		     <div class="none" id="err_tip">!&nbsp;用户名不能为空</div>
		    <input type="button" value="确定(s)" id="submitBtn" accesskey="s" class="submit" onclick="loginValid()" />
		    <input type="reset" value="重置(r)"  id="resetBtn" accesskey="r" class="submit"/>
		  </td>
		</tr>
	  </table>
</form>

<script type="text/javascript">
<!--
	 var getCookie = function(name){
		  var start  , start1 ,end , value;
		  start1 = document.cookie.indexOf(name + "="); 
		  if (start1== -1){
		   return 0; 
		  }else{ 
			start = document.cookie.indexOf("=",start1)+1;  
			end = document.cookie.indexOf(";",start); 
			if (end == -1) end = document.cookie.length;
			value  = document.cookie.substring(start,end); 
			if (value==null) return 0; 
			else return value;
		  } 
	  }

	var setCookie = function(name, value,days) { 
	var date = new Date(); 
	date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 
	var expires = "; expires=" + date.toGMTString(); 
	document.cookie = name + "=" + value + expires + "; path=/"; 
   } 

	  var verifyNumber = function (){
	    var count = getCookie('count');
		var userName = getCookie('www');
		if(parseInt(count) >= 5){
		  document.getElementById('inputCode').className = 'show';
		  document.getElementById('err_tip').className = 'show';
		  document.getElementById('err_tip').innerHTML = '请不要尝试非法登录！';
          document.getElementById('submitBtn').disabled = true;
          document.getElementById('resetBtn').disabled = true;
		  return;
		}else if(parseInt(count) >= 1){
		  document.getElementById('inputCode').className = 'show';
		}
		if(userName != ''){
		    document.getElementById('userName').value = unescape(userName);
			document.getElementById('pass').focus();			
		}else{
  		    document.getElementById('userName').focus();
	    }
	  }
    
	function loginValid(){
	  if(document.getElementById('userName').value == ""){
	    document.getElementById('err_tip').className = 'show';
		document.getElementById('err_tip').innerHTML = '用户名不能为空';
		return;
	  }else if(document.getElementById('pass').value == ""){
	   	 document.getElementById('err_tip').className = 'show';
		 document.getElementById('err_tip').innerHTML = '密码不能为空';
	  }else if(document.getElementById('code').value == "" && parseInt(getCookie('count')) > 1){
	   	 document.getElementById('err_tip').className = 'show';
		 document.getElementById('err_tip').innerHTML = '验证码不能为空';	   
	  }else{
	    setCookie('www' , escape(document.getElementById('userName').value) ,30);
	    document.getElementById('form').submit();
	  }
	}

	document.onkeydown = function(e){
		var key = window.event?window.event:e;
		if(key.keyCode==13)
		{
			loginValid();
		}
	}
	window.status = "按住Alt键加对应字母 可直接链接";
//-->
</script>



 </body>
</html>
